<template>
  <div class="page">
    <h1>电影详情页面</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: 'hello'
    }
  },

  methods: {
    refresh() {}
  },

  created() {
    console.log('created')
  },

  // 组件级别的守卫
  beforeRouteEnter(to, from, next) {
    console.log('组件级 beforeRouteEnter', this)
    next((vm) => {
      // vm 就是当前组件的 this 实例
      console.log('vm', vm)
      vm.refresh()
    })
  },

  // beforeRouteUpdate(to, from) {
  //   console.log('组件级 beforeRouteUpdate')
  // },

  beforeRouteLeave(to, from) {
    const flag = window.confirm('你确认要离开嘛?')
    console.log('flag', flag)
    return flag
  }
}
</script>
